﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using FlickrXplorer.Web.Objects;

namespace FlickrXplorer.Web.Plugin
{
  public class PluginBuilder
  {
    private FlickrXplorerPlugin plugin;
    private PageArea currentPageArea;
    private BuilderEventProxy currentEventProxy;

    public PluginBuilder(FlickrXplorerPlugin plugin)
    {
      this.plugin = plugin;
    }

    public PluginBuilder When
    {
      get { return this; }
    }

    public PluginBuilder MainPhotoIsLoading
    {
      get
      {
        this.currentEventProxy = new LoadMainPhotoEventProxy(this.plugin);
        this.currentPageArea = PageArea.AbovePhoto;
        return this;
      }
    }

    public PluginBuilder SidebarPhotoIsLoading
    {
      get
      {
        this.currentPageArea = PageArea.AbovePopularTags;
        return this;
      }
    }

    public PluginBuilder GetTitleFrom(Func<PhotoDetail, String> titleMethod)
    {
      LoadMainPhotoEventProxy proxy = this.currentEventProxy as LoadMainPhotoEventProxy;
      proxy.TitleMethod = titleMethod;
      return this;
    }

    public PluginBuilder And
    {
      get { return this; }
    }

    public PluginBuilder GetBodyFrom(Func<PhotoDetail, String> bodyMethod)
    {
      LoadMainPhotoEventProxy proxy = this.currentEventProxy as LoadMainPhotoEventProxy;
      proxy.BodyMethod = bodyMethod;
      return this;
    }

  }
}
